package com.uzhie.component;

import com.alibaba.fastjson.JSON;
import com.uzhie.web.dao.PassengerDAO;
import com.uzhie.web.dao.VehicleDAO;
import com.uzhie.jt808.jt1078.entity.JT_1005;
import com.uzhie.web.module.Passenger;
import com.uzhie.web.module.Vehicle;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 视频分析上传组件
 */
@Component
public class VideoAnalyseComponent {

    private Logger logger = Logger.getLogger(this.getClass());

    @Autowired
    private PassengerDAO passengerDAO;
    @Autowired
    private VehicleDAO vehicleDAO;
    /**
     *
     * @param order
     * @param simNumber
     */
    public void addPassenger(JT_1005 order,String simNumber){
        List<Vehicle> vehicle = vehicleDAO.selectVehicleBySimNumber(simNumber);
        if (vehicle!=null && vehicle.size() >0) {
            Passenger passenger = Passenger.getPasseger(order,vehicle.get(0));
            passengerDAO.insert(passenger);
            logger.info("收到了视频分析数据，内容为" + JSON.toJSONString(passenger));
        }
    }
}
